<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>资招</title>
	<link rel="stylesheet" type="text/css" href="/build/css/base.css"/>
	<link rel="stylesheet" type="text/css" href="/build/css/style.css">
	<link rel="stylesheet" type="text/css" href="/build/css/main.css">
	<script src="/build/public/vue.js" charset="utf-8"></script>
	<script src="/build/public/vue-resource.js" charset="utf-8"></script>
	<script src="/build/js/config.js" charset="utf-8"></script>
	<script src="/build/js/common.js" charset="utf-8"></script>
</head>
<body>
	<script type="text/javascript">
		loader.init('正在授权中');
	</script>
	<div id="container" style="padding-bottom:50px;">
	</div>
<script type="text/javascript">

var vm = new Vue({
	el:"#container",
	data:{
		
	},
	mounted:function(){
		this.$nextTick(function(){
			//验证请求
			post("/weiXinOAuth/advisor/auth-login", {code:vm.getParameter('code')},function(res){	
					console.log(vm.getParameter('code'))
					if(res.data.isRegist==true){
    					loader.remove();
						if(res.data.isBindingNumber==true){
							window.localStorage.setItem(siteTokenKey,res.data.token);
							window.location.href='/index.html';
						}else{
							window.location.href='/invite_code.html?code='+vm.getParameter('code')+'&unionId='+res.data.unionId;
						}
					}else {
	    				loader.remove();
						window.location.href='/invite_code.html?code='+vm.getParameter('code')+'&unionId='+res.data.unionId;
					} 
			});
		})
	},
	methods:{
		getParameter:function(name){                        //获取链接参数
			var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
 			var r = window.location.search.substr(1).match(reg);
 			if(r!=null)return  unescape(r[2]); return null;
		},
		
	}
})
</script>
</body>
</html>
